#include <stdio.h>
#include <stdlib.h>
#include "../heads/Queue.h"

Queue createQueue() {
    return createLinkedList();
}

void enqueue(Queue *queue, int data) {
    addToListTail(queue, data); // 队列的入队操作等同于链表的尾部插入
}

int dequeue(Queue *queue) {
    if (isQueueEmpty(queue)) {
        fprintf(stderr, "队空异常.\n");
        exit(EXIT_FAILURE);
    }
    int data = queue->head->next->data;
    removeFromList(queue, data);
    return data;
}

int frontQueue(Queue *queue) {
    if (isQueueEmpty(queue)) {
        fprintf(stderr, "队空异常.\n");
        exit(EXIT_FAILURE);
    }
    return queue->head->next->data;
}

int isQueueEmpty(Queue *queue) {
    return queue->head->next == NULL;
}

void destroyQueue(Queue *queue) {
    destroyList(queue);
}
